作者:别装了gg_925 | 来源:互联网 | 2024-11-16 10:52
Thisarticlediscussestheincompatibilityissuesencounteredwhenusing`disallowAnonymousFunctions`and`esnext`together,particularlyinthecontextofmodernJavaScriptcodingpractices.
Hello,
I am encountering an issue where `esnext` and `disallowAnonymousFunctions` settings are not working well together. Specifically, I have both `esnext` and `disallowAnonymousFunctions` set to `true` in my configuration. Here is the code snippet causing the problem:
class Test {
constructor(first, last) {
this.first = first;
this.last = last;
}
getName() {
return `${this.first} ${this.last} is a name.`;
}
}
When running the linter, I receive two errors stating that 'Anonymous functions need to be named.' These errors are pointing to the positions between the `constructor` keyword and the opening parenthesis, as well as between the `getName` method and its opening parenthesis.
This issue seems to stem from the `disallowAnonymousFunctions` rule being overly strict with modern ES6+ syntax, which often uses concise method definitions without explicit function names. To resolve this, you might consider adjusting the rule or using a different linter configuration that better supports ES6+ features while maintaining code quality standards.
For further assistance, you can post a bounty on this issue via Bountysource. This issue is sourced from the open-source project: jscs-dev/node-jscs. At this point, only major and CST-related bugs will be fixed.